#include<bits/stdc++.h>
using namespace std;
const int N=1e6+100;
int t,n,m,sl,sv,nc,np,nowp;
double nv;
int p[N];
struct car{
    int d,v,a;
    int l,r;
}c[N];
bool cmp(car a,car b){
    return a.r<b.r;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--){
        nc=0,np=0;
        scanf("%d%d%d%d",&n,&m,&sl,&sv);
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&c[i].d,&c[i].v,&c[i].a);
            c[i].l=1e7,c[i].r=-1e7;
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(c[j].d<=p[i]){
                    nv=sqrt(c[j].v*c[j].v+2*c[j].a*(p[i]-c[j].d));
                    if(nv>sv){
                        c[j].l=min(c[j].l,p[i]);
                        c[j].r=max(c[j].r,p[i]);
                        c[j].r=min(c[j].r,sl);
                    }
                }
            }
        }
        sort(c+1,c+n+1,cmp);
        for(int i=1;i<=n;i++)
            if(c[i].l!=1e7&&c[i].r!=-1e7){
                nc=n-i+1;
                break;
            }
        nowp=c[n-nc+1].r;    
        for(int i=n-nc+1;i<=n;i++){
            if(i==n-nc+1)
                np++;
            else
                if(c[i].l<=nowp&&c[i].r>=nowp)
                    continue;
                else{
                    nowp=c[i].r;
                    np++;
                }
        }
        printf("%d %d\n",nc,m-np);
    }
    return 0;
} 